import Vue from 'vue'
import Router from 'vue-router'
const List = resolve => require(['../components/List'], resolve) 
const Login = resolve => require(['../components/Login'], resolve) 
const Word = resolve => require(['../components/Word'], resolve) 
const Index = resolve => require(['../components/Index'], resolve) 
const Level = resolve => require(['../components/Level'], resolve) 
const Personal = resolve => require(['../components/Personal'], resolve) 
const ChangePassword = resolve => require(['../components/ChangePassword'], resolve) 
const ChangeMessage = resolve => require(['../components/ChangeMessage'], resolve) 

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: Index,
      meta:{title:'学习中心'}
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/word',
      component: Word
    },
    {
      path: '/list',
      component: List,
      meta:{title:'挑选词本'}
    },
    {
      path: '/level',
      component: Level
    },
    {
      path: '/personal',
      component: Personal,
      meta:{title:'个人中心'}
    },
    {
      path: '/change-password',
      component: ChangePassword,
      meta:{title:'修改密码'}
    },
    {
      path: '/change-message',
      component: ChangeMessage,
      meta:{title:'修改资料'}
    }
  ],scrollBehavior (to, from, savedPosition) {
    if(savedPosition) {
        setTimeout(() => {
            window.scrollTo(savedPosition.x, savedPosition.y)
        }, 300)
    }else{
    return { x: 0, y: 0 }
    }
  }
})
